<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>正则小插件</title>
    <script src="https://cdn.bootcss.com/jquery/1.11.0/jquery.min.js"></script>
</head>
<body>
    <form id="demo" action="gogo.php" style="width:1200px ;margin:0 auto;">
        <p>姓名<input type="text" name="xingming" required="true" required-msg="未填写姓名" ></p>
        <p>班级<input type="text" name="banji" required="true" required-msg="未填写班级" ></p>
        <p>电话<input type="text" name="phone" data-reg="^(\S)+$&&^((13[0-9])|(14[5|7])|(15([0-3]|[5-9]))|(18[0,5-9]))\d{8}$" reg-msg="不能为空&&手机格式不正确"></p>
        <input type="checkbox" name="sex" check-class="性别"> 男
        <input type="checkbox" name="sex" check-class="性别"> 女
        <input type="checkbox" name="sex" check-class="性别"> 男女男
        <p><input type="checkbox" name="agree" check-single="协议" check-single-msg="请勾选同意协议">是否同意协议</p>
        <div><button id="btn" type="submit">提交</button></div>
    </form>
</body>
<script src="valid_ver1.0.js"></script>
<script>
    $('#btn').click(function(){
        var newParams = {
            callback:function(msg,elm){
                alert(msg)
            },
            beforesubmit:function(msg){
                alert(msg)
            },
            Ajax:true,
            AjaxPost:true
        }
        $('#demo').valid(newParams)
        // if($('#demo').valid(newParams)){
        //     $('#demo').submit()
        // }
        
    })

    function showError(msg){
        alert(msg)
    }
</script>
</html>